﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="lp_Report_addresslist.aspx.cs"
    Inherits="ZLDC.Estate.Quantify.Report.lp_Report_addresslist" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../css/main1.css" rel="stylesheet" type="text/css" />

    <script src="../../js/jquery-1.3.2.min.js" type="text/javascript"></script>
 <script src="../charts/FusionCharts.js" type="text/javascript"></script>
    <script src="../charts/highcharts1.js" type="text/javascript"></script>
    <script src="../js/GetUrl.js" type="text/javascript"></script>
    <style type="text/css">
        </style>

    <script type="text/javascript">
        var depttype = '<%=depttype %>';
        var deptid = '<%=deptid %>';
        var type = '<%=type %>';
        window.onload = function ajaxList() {

            if (depttype == '营业大部' || depttype == '营业部' || depttype == '区域') {
                $.ajax({
                    type: "POST",
                    url: "../AjaxServer.aspx",
                    dataType: 'json',
                    data: "alt=deptlist&deptid=" + deptid + "&depttype=" + depttype + "",
                    processData: false,
                    timeout: '10000',
                    success: function(msg) {

                        divlist(msg);

                    },
                    error: function() {
                        document.getElementById('worklist').innerHTML = "系统繁忙";
                    }

                });
            }
        }
        function divlist(msg) {
            var arr = [];
            arr.push("<table width='580px' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
            arr.push("<tr bgcolor=\"#353c44\" >");
            arr.push("<td width=\"80px\"  style='text-align: center;background-color: #d3eaef'  >");
            arr.push("<div >地区</div>");
            arr.push("</td>");
            arr.push("<td width=\"80px\"  style='text-align: center;background-color: #d3eaef'>");
            arr.push("<div >考核人数</div>");
            arr.push("</td>");
            arr.push("<td width=\"80px\"  style='text-align: center;background-color: #d3eaef'  >");
            arr.push("<div >平均分</div>");
            arr.push("</td>");
            arr.push("<td width=\"100px\"  style='text-align: center;background-color: #d3eaef'>");
            arr.push("<div >未达标人数</div>");
            arr.push("</td>");
            arr.push("<td width=\"120px\"  style='text-align: center;background-color: #d3eaef'>");
            arr.push("<div >(经理)昨日未检查</div>");
            arr.push("</td>");
            arr.push("<td width=\"120px\"  style='text-align: center;background-color: #d3eaef'>");
            arr.push("<div >(经理)昨日未部署</div>");
            arr.push("</td>");

            arr.push("</tr>");

            for (var i = 0; i < msg.msg.length; i++) {

                if (i % 2 == 0)
                    arr.push("<tr bgcolor='#FFFFFF'>");
                else
                    arr.push("<tr bgcolor='#EEEDED'>");
                    arr.push("<td height='20' class='STYLE6'  style='text-align: center;'>");
                if (type == "2") {
                    arr.push(msg.msg[i].work_deptname);
                 }
                else {
                    if (msg.depttype == '区域') {
                        arr.push("<a onclick=\"workyestoday(" + msg.msg[i].work_deptid + ",'" + msg.msg[i].work_deptname + "')\">" + msg.msg[i].work_deptname + "</a>");
                    }
                    else {
                        arr.push("<a onclick=\"worklist(" + msg.msg[i].work_deptid + ",'" + msg.msg[i].work_deptname + "')\">" + msg.msg[i].work_deptname + "</a>");
                    }
                }
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(msg.msg[i].work_testnumber);
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(msg.msg[i].work_average);
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(msg.msg[i].work_standard);
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(msg.msg[i].work_yestoday);
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(msg.msg[i].work_deployment);
                arr.push("</td>");

                arr.push("</tr>");

            }
            arr.push("</table>");

            document.getElementById('worklist').innerHTML = arr.join('');
        }
        function workyestoday(deptid, deptname) {
            var today = new Date();            //月份为0-11
            var yesterday_milliseconds = today.getTime() - 1000 * 60 * 60 * 24;
            var yesterday = new Date();
            yesterday.setTime(yesterday_milliseconds);

            var strYear = yesterday.getFullYear();
            var strDay = yesterday.getDate();
            var strMonth = yesterday.getMonth() + 1;
            if (strMonth < 10) {
                strMonth = "0" + strMonth;
            }

            var strYesterday = strYear + "-" + strMonth + "-" + strDay;

            parent.closeTab(deptname);
            // self.parent.parent.addTab(deptname, "../Quantify/lp_Report_list.aspx?type=1&deptname=" + escape(deptname) + "&deptid=" + deptid + "&statrday='" + strYesterday + "'&endday='" + strYesterday + "'", "icon-nav");
            parent.addTab(deptname, "../Quantify/lp_YesterDay.aspx?type=1&deptname=" + escape(deptname) + "&deptid=" + deptid + "&statrday='" + strYesterday + "'&endday='" + strYesterday + "'", "icon-nav");
        }

        function worklist(deptid, deptname) {
            var today = new Date();            //月份为0-11
            var yesterday_milliseconds = today.getTime() - 1000 * 60 * 60 * 24;
            var yesterday = new Date();
            yesterday.setTime(yesterday_milliseconds);

            var strYear = yesterday.getFullYear();
            var strDay = yesterday.getDate();
            var strMonth = yesterday.getMonth() + 1;
            if (strMonth < 10) {
                strMonth = "0" + strMonth;
            }

            var strYesterday = strYear + "-" + strMonth + "-" + strDay;

            parent.closeTab("昨日 " + deptname);
            parent.addTab("昨日 " + deptname, "../Quantify/Report/lp_Report_addresslist.aspx?type=1&deptname=" + escape(deptname) + "&deptid=" + deptid + "&statrday='" + strYesterday + "'&endday='" + strYesterday + "'", "icon-nav");


        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <table>
        <tr>
            <td>
                <div id="worklist" style="margin: 15px 15px 5px 15px;">
                  <img src="../../images/loading.gif" />
                </div>
            </td>
            <td>  <div id='divchart' >
            <img src="../../images/loading.gif" />
</div>
<script type="text/javascript">

    $.ajax({
        type: "POST",
        url: "../AjaxServer.aspx",
        dataType: 'json',
        data: "alt=chart&deptid=" + deptid + "&depttype=" + depttype + "",
        processData: false,
        timeout: '10000',
        success: function(msg) {
            chartlist(msg);
        },
        error: function() {
            document.getElementById('divchart').innerHTML = "系统繁忙";
        }

    });
    function chartlist(msg) {

        var yesdaychart = "";
        var statrday = <%=statrday %>;
        var endday = <%=endday %>;
        if (msg.msg.length > 0) {
            yesdaychart = "[";
            for (var i = 0; i < msg.msg.length; i++) {
                yesdaychart += "{name: '" + msg.msg[i].basisname + msg.msg[i].actual_number + "', y: " + msg.msg[i].actual_goal + ",dataLabels:'" + GetUrl(msg.msg[i].basisname) + "&deptid=" + deptid + "&addDate2=" + endday + "" + "&addDate1=" + statrday + "'},";
            }
            yesdaychart = yesdaychart.substring(0, yesdaychart.length - 1);
            yesdaychart += "]";
            yesdaychart = eval('' + yesdaychart + '');

            chartxsDeptlist(yesdaychart, '昨日工作', 'divchart',1);
        }
    }</script>
            </td>
        </tr>
    </table><%=ZLDC.Topo.BLL.Estate.lp_Basis.GetManagerlh()%>
    </form>
</body>
</html>
